const modulesFiles = require.context('./components', true, /index\.vue$/)
const components = []
modulesFiles.keys().forEach(key => {
  const component = modulesFiles(key)
  if (!component.default || !component.default.name) {
    return
  }
  component.install = function(Vue) {
    Vue.component(this.default.name, this.default)
  }
  if (window.Vue) {
    window[component.default.name] = component
    Vue.use(component.install)
  }
  components.push(component)
})
export default {
  install(Vue) {
    components.forEach(component => {
      Vue.use(component)
    })
  }
}
